package demogeneric;

public class Test {
    public static void main(String[] args) {
        MyArray<Integer> myArray1 = new MyArray<>();

        myArray1.setArray(0, 11);
        //myArray1.setArray(1, "xixi");//报错 该顺序表已定义为整型
        myArray1.setArray(1, 23);//在编译时，自动进行类型检查

        Integer val1 = myArray1.getVal(0);//在编译时，自动进行类型转换
        System.out.println(val1);

        MyArray<String> myArray2 = new MyArray<>();

        myArray2.setArray(0, "hello");
        myArray2.setArray(1, "world");

        String val2 = myArray2.getVal(0);
        System.out.println(val2);
    }

    public static void main1(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setArray(0, 1);
        myArray.setArray(1, "hello");

        String ret = (String)myArray.getVal(1);
        System.out.println(ret);

        System.out.println(myArray.getVal(1));
    }
}
